<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" xmlns:head="http://www.w3.org/1999/html">
<head th:include="public/public_css::public_css ('异常处理页面')" />

<body style="background-color: #f2f2f2;">
<div class="layui-fluid larry-wrapper">
    <div class="layui-card">
        <div class="layui-row layui-col-space30">
        <div class="layui-col-xs24">
            <!--列表-->
            <section class="panel panel-padding layui-card-body" >
                <div class="pro">
                    <div class="layui-inline">
                        <label class="layui-input-inline">箱编号</label>
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" th:value="${xbh}" name="xhbh" id="xbh" />
                            </div>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-input-inline">异常原因</label>
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="yc" id="yc" />
                            </div>
                        </div>
                    </div>
                        <div class="layui-input-block"  style="float: right">
                            <button class="layui-btn" lay-submit lay-filter="fuhe">取消复核</button>
                            <button class="layui-btn" lay-submit lay-filter="out">处理完成</button>
                            <button class="layui-btn" lay-submit lay-filter="print">打印快递面单</button>
                        </div>
                    <table id="table" class="table text-nowrap"></table>
                </div>
                <div class="pro">
                    <p>出库异常清单</p>
                    <table id="table2" class="table text-nowrap"></table>
                </div>
            </section>
        </div>
    </div>
    </div>
</div>

</body>


<div th:include="public/public_js::public_js"></div>
<script>
    layui.use(['myform','zzpUtils','form','laydate','jquery','zzpValidation'],function () {
        var form = layui.form,
         zzpUtils= layui.zzpUtils,
            $ = layui.jquery,
            tablebtn = layui.tablebutton;
        var $table = zzpUtils.table({
            elem: '#table',
            isApi: true,
            pagination:false,
            showColumns: false,
            url: '[{}]',
            columns: [{
                field: '',
                checkbox: true
            },{
                field: 'hpbh',
                title: '货品编号'
            },{
                field: 'hpmc',
                title: '货品名称'
            },{
                field: 'sl',
                title: '数量'
            },{
                field: 'zl',
                title: '重量',
            }],
            detailFormatter: function (index, row) {
                return "这里就没有确定过11";
            },
            onDblClickRow:function ( row,index) {/*双击行展示详情*/
                btn_cha(row.id);
            }

        });
        var $table2 = zzpUtils.table({
            elem: '#table2',
            isApi: true,
            pagination:true,
            showColumns: false,//隐藏显示列
            url: '[{}]',
            columns: [{
                field: '',
                checkbox: true
            }, {
                field: 'fydh',
                title: '发运订单'
            },{
                field: 'khmc',
                title: '客户名称'
            },{
                field: 'lxr',
                title: '联系人'
            },{
                field: 'dz',
                title: '地址',
            },{
                field: 'xbh',
                title: '箱编号'
            }],
            detailFormatter: function (index, row) {
                return "这里就没有确定过11";
            },
            onDblClickRow:function ( row,index) {/*双击行展示详情*/
                btn_cha(row.id);
            }

        });
        var xbh=$("#xbh").val();
        var fhid="";
        var weigth="";
        $.ajax({
            type: "GET",
            url: "/zxsdwms/wmsreview/getEdit/"+xbh,
            dataType: "JSON",
            async: false,
            contentType: 'application/json',
            success: function (data) {
                if(data.data==""){
                    layer.msg(data.title+data.message);
                }else{
                    fhid=data.data.fyid;
                    weigth=data.data.sjzl;
                    $table.bootstrapTable('append', data.data.rows);
                }
            },
            error: function () { console.log("Error"); }
        });
        var query={
            fyzt:2,
            page:1,
            rows:10
        };
        $.ajax({
            type: "POST",
            url: "/zxsdwms/wmsreview/list",
            dataType: "JSON",
            async: false,
            contentType: 'application/json',
            data:JSON.stringify(query),
            success: function (data) {
                $table2.bootstrapTable('append', data.rows);
            },
            error: function () { console.log("Error"); }
        });
        $(".inline-search-btn").on('click',function () {
            zzpUtils.refreshTable("#table");
        })
        //取消复核
        form.on("submit(fuhe)",function(data){
            var xbh=$("#xbh").val();
            zzpUtils.confirm("确认取消复核吗",function(index){
                $.ajax({
                    type: "GET",
                    url: "/zxsdwms/wmsreview/cancel/"+xbh,
                    dataType: "JSON",
                    async: false,
                    contentType: 'application/json',
                    success: function (data) {
                        if(data.type!="error"){
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭
                        }
                        if(data.message!=""){
                            layer.msg(data.message);
                        }else{
                            layer.msg(data.title);
                        }
                    },
                    error: function () { console.log("Error"); }
                });
            })
        });
        form.on("submit(out)",function(data){
            console.log('111111111',fhid);
            var ycyy=$("#yc").val();
            console.log('ycyy====',ycyy);
            var query=[{
                fyzt:1,
                fyid:fhid,
                ycyy:ycyy
            }];
            zzpUtils.action({
                url: "/wmsreview/edit/",
                data:JSON.stringify(query),
                success: function (data) {
                    setTimeout(function () {
                        layer.msg(data.title);
                    }, 500);
                    zzpUtils.refreshTable("#table");
                }, error: function (xhr, textStatus) {
                    console.log(textStatus);
                    console.log(xhr)
                }
            })
        })
        form.on("submit(print)",function(data){
            zzpUtils.action({
                url: "/wmsreview/print",
                data:JSON.stringify({weigth:weigth,xbh:xbh}),
                success: function (data) {
                    var LODOP=getLodop();
                    LODOP.PRINT_INIT('打印快递面单');
                    LODOP.ADD_PRINT_URL(0, 0, 746, '100%', data.data[0]);
                    LODOP.SET_PRINT_STYLEA(0, 'HOrient', 3);
                    setTimeout(function () {
                        LODOP.PREVIEW();
                    }, 500);
                    zzpUtils.refreshTable("#table");
                }, error: function (xhr, textStatus) {
                    console.log(textStatus);
                    console.log(xhr)
                }
            })
        })
    });
</script>
</html>